package sistemasdistribuidos;

import classesBase.ModelaTabela;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.text.SimpleDateFormat;
import javax.swing.ListSelectionModel;
import telasMensagem.Bloqueio;
import telasMensagem.SimNao;

public class AgendaBanhoTosa extends javax.swing.JDialog {

    ModelaTabela modela = new ModelaTabela();
    ModelaTabela modelaS = new ModelaTabela();
    byte parImpar = 0;
    static byte flag = 1;
    static int flag2 = 1;
    SimpleDateFormat formatar = new SimpleDateFormat("yyyy-MM-dd");
    static boolean conf = false;
    File txt = new File("C:\\Ziviane10\\Docs\\ConfigAgenda.ini");

    public AgendaBanhoTosa(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        tabela();

        jTextFieldAnimal.setEditable(false);
        jTextFieldCodigo.setEditable(false);
        jTextFieldCodigoAnimal.setEditable(false);
        jTextFieldCodigoDono.setEditable(false);
        jTextFieldDono.setEditable(false);
        habilita(false, true);
        jTabbed.setEnabledAt(0, true);

        jCalendarData.addPropertyChangeListener(new java.beans.PropertyChangeListener() {//GERA A AÇÃO PRA TROCA DE PROPRIEDADE  
            public void propertyChange(java.beans.PropertyChangeEvent evt) { //GERA EVENTO  
                // jCalendar1PropertyChange(evt);
            }
        });

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                if (flag == 0) {
                    bloqueio("<html>Por favor, salve "
                            + "os dados editados antes de deixar esta tela!<html>");
                } else {
                    dispose();
                }
            }
        });
    }

    public AgendaBanhoTosa(java.awt.Frame parent, boolean modal, int fl, int cod) {
        super(parent, modal);
        initComponents();
        tabela();
        flag2 = fl;
        jTabbed.remove(jPanelDetalhes);
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        jButtonIncluir.setText("Reagendar");
        jButtonDeletarAgendamentos.setText("Cancelar Alteração");
    }

    public void bloqueio(String msn) {
        Bloqueio b = new Bloqueio(null, true, msn);
        b.setLocationRelativeTo(null);
        b.setVisible(true);
    }

    public void atualiza(String prof) {
        //for para percorrer os resultados da query
        //if para verificar se o horario do resultado analisado é isgual ao 
        //da agenda
        //se for preenche os campos
        //senão pula pro próximo
    }

    public static void apaga(boolean b) {
        conf = b;
    }

    public void limpar() {
        jLabelHora.setText(null);
        jTextFieldCodigo.setText(null);
        jTextFieldAnimal.setText(null);
        jLabelProfissional.setText(null);
        jTextFieldCodigoAnimal.setText(null);
        jTextFieldDono.setText(null);
        jTextFieldCodigoDono.setText(null);
        jTextPaneObservacoes.setText(null);

        modelaS.setRowCount(0);
        modelaS.setColumnIdentifiers(new String[]{"Código", "Descrição", "Duração", "Preço"});
        jTableServiços.setModel(modelaS);
    }

    public void tabela() {

        modela.setColumnIdentifiers(new String[]{"Horário", "Código", "Animal"});

        String[] inicio = null;
        String[] fim = null;
        String[] intervalo = null;

        try {
            FileReader fr = new FileReader(txt);
            BufferedReader br = new BufferedReader(fr);
            int i = 0;
            while (i < 3) {
                String line[] = br.readLine().split("=");
                if (i == 0) {
                    modela.addRow(new String[]{line[1], "", ""});
                    inicio = line[1].split(":");
                }
                if (i == 1) {
                    fim = line[1].split(":");
                }
                if (i == 2) {
                    intervalo = line[1].split(":");
                }
                i++;
            }
        } catch (Exception ex) {
            System.out.println(ex);
        }
        int Ihora = Integer.parseInt(inicio[0]);
        int Imin = Integer.parseInt(inicio[1]);
        int Fhora = Integer.parseInt(fim[0]);
        int Fmin = Integer.parseInt(fim[1]);
        int Bhora = Integer.parseInt(intervalo[0]);
        int Bmin = Integer.parseInt(intervalo[1]);

        int i = 0;

        while (i == 0) {
            Ihora = Ihora + Bhora;
            Imin = Imin + Bmin;
            if (Imin >= 60) {
                Ihora = Ihora + 1;
                Imin = Imin - 60;
            }
            if (Ihora >= Fhora) {
                if (Imin > Fmin) {
                    Imin = Fmin;
                    i = 1;
                }
                if (Imin == 0) {
                    modela.addRow(new String[]{String.valueOf(Fhora) + ":" + String.valueOf(Imin) + "0", "", ""});
                } else {
                    modela.addRow(new String[]{String.valueOf(Fhora) + ":" + String.valueOf(Imin), "", ""});
                }
            } else {
                if (Imin == 0) {
                    modela.addRow(new String[]{String.valueOf(Ihora) + ":" + String.valueOf(Imin+"0"), "", ""});
                } else {
                    modela.addRow(new String[]{String.valueOf(Ihora) + ":" + String.valueOf(Imin), "", ""});

                }
            }
        }
        jTableAgenda.setModel(modela);
        jTableAgenda.getColumnModel().getColumn(2).setPreferredWidth(250);
        jTableAgenda.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jTableAgenda.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    
    public void buscaAgendamento(){
        /*
        
        Método que preencherá a tabela
        */
    }

    public void habilita(boolean favor, boolean contrario) {
        jTabbed.setEnabledAt(0, contrario);
        jButtonBuscarAnimal.setEnabled(favor);
        jTextPaneObservacoes.setEditable(favor);
        jButtonAdicionarServico.setEnabled(favor);
        jTextFieldAddServico.setEnabled(favor);
        jButtonDeletarServico.setEnabled(favor);
        jTableServiços.setEnabled(favor);
        jButtonReagendar.setEnabled(contrario);

    }

    public void tabelaServicos() {

        modelaS.setColumnIdentifiers(new String[]{"Código", "Descrição", "Duração", "Preço"});
        modelaS.setRowCount(0);
        //setar serviços do agendamento aqui:
        modelaS.addRow(new String[]{"156", "Bainho", "365 dias", "1"});
        modelaS.addRow(new String[]{"156", "Tosa", "3hrs", "2"});
        modelaS.addRow(new String[]{"156", "unhas", "1", "3"});
        modelaS.addRow(new String[]{"156", "perfume", "8", "4"});
        modelaS.addRow(new String[]{"156", "kjhg", "8", "5"});
        jTableServiços.setModel(modelaS);
    }

    public static void informacoes(String nomeA, String nomeD, String codA, String codD) {
        jTextFieldAnimal.setText(nomeA);
        jTextFieldDono.setText(nomeD);
        jTextFieldCodigoAnimal.setText(codA);
        jTextFieldCodigoDono.setText(codD);

        //trocar o nome pelo ID do animal 
        // e do dono, depois buscar no banco e joga na tela
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabelMsg14 = new javax.swing.JLabel();
        jTabbed = new javax.swing.JTabbedPane();
        jPanelAgenda = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableAgenda = new javax.swing.JTable();
        jComboBoxProfissional = new javax.swing.JComboBox();
        jLabelMsg12 = new javax.swing.JLabel();
        jCalendarData = new com.toedter.calendar.JCalendar();
        jLabelMsg13 = new javax.swing.JLabel();
        jLabelMsg11 = new javax.swing.JLabel();
        jButtonIncluir = new javax.swing.JButton();
        jButtonDeletarAgendamentos = new javax.swing.JButton();
        jLabelMsg15 = new javax.swing.JLabel();
        jPanelDetalhes = new javax.swing.JPanel();
        jLabelMsg19 = new javax.swing.JLabel();
        jTextFieldCodigo = new javax.swing.JTextField();
        jLabelMsg16 = new javax.swing.JLabel();
        jTextFieldAnimal = new javax.swing.JTextField();
        jButtonBuscarAnimal = new javax.swing.JButton();
        jLabelMsg17 = new javax.swing.JLabel();
        jLabelMsg18 = new javax.swing.JLabel();
        jTextFieldDono = new javax.swing.JTextField();
        jTextFieldAddServico = new javax.swing.JTextField();
        jLabelMsg20 = new javax.swing.JLabel();
        jButtonAdicionarServico = new javax.swing.JButton();
        jButtonDeletarServico = new javax.swing.JButton();
        jTextFieldCodigoAnimal = new javax.swing.JTextField();
        jLabelMsg21 = new javax.swing.JLabel();
        jLabelMsg22 = new javax.swing.JLabel();
        jTextFieldCodigoDono = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTableServiços = new javax.swing.JTable();
        jLabelMsg23 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTextPaneObservacoes = new javax.swing.JTextPane();
        jButtonReagendar = new javax.swing.JButton();
        jButtonEditar = new javax.swing.JButton();
        jLabelHora = new javax.swing.JLabel();
        jLabelProfissional = new javax.swing.JLabel();
        jLabelMsg26 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Agenda Banho Tosa");

        jPanel1.setBackground(new java.awt.Color(255, 102, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createMatteBorder(3, 3, 3, 3, new java.awt.Color(0, 0, 0)));

        jLabelMsg14.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N
        jLabelMsg14.setText("Agenda de Banho e Tosa");

        jTabbed.setBackground(new java.awt.Color(255, 102, 0));
        jTabbed.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N

        jPanelAgenda.setBackground(new java.awt.Color(255, 102, 0));
        jPanelAgenda.setBorder(javax.swing.BorderFactory.createMatteBorder(3, 3, 3, 3, new java.awt.Color(0, 0, 0)));

        jTableAgenda.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
        jTableAgenda.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jTableAgenda.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Horário", "Código", "Cachorro"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableAgenda.setRowHeight(25);
        jTableAgenda.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableAgendaMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jTableAgenda);

        jComboBoxProfissional.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jComboBoxProfissional.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione", "Teste" }));
        jComboBoxProfissional.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxProfissionalActionPerformed(evt);
            }
        });

        jLabelMsg12.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg12.setText("Profissional:");

        jCalendarData.setBackground(new java.awt.Color(255, 255, 255));
        jCalendarData.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2));
        jCalendarData.setDecorationBackgroundColor(new java.awt.Color(255, 255, 255));
        jCalendarData.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        jCalendarData.setWeekdayForeground(new java.awt.Color(255, 102, 0));

        jLabelMsg13.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg13.setText("Data da Agenda:");

        jLabelMsg11.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/banho.png"))); // NOI18N

        jButtonIncluir.setBackground(new java.awt.Color(255, 255, 255));
        jButtonIncluir.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonIncluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonIncluir.setText("Incluir Agendamento");
        jButtonIncluir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonIncluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonIncluirActionPerformed(evt);
            }
        });

        jButtonDeletarAgendamentos.setBackground(new java.awt.Color(255, 255, 255));
        jButtonDeletarAgendamentos.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonDeletarAgendamentos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/osso.png"))); // NOI18N
        jButtonDeletarAgendamentos.setText("Deletar Agendamento");
        jButtonDeletarAgendamentos.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonDeletarAgendamentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDeletarAgendamentosActionPerformed(evt);
            }
        });

        jLabelMsg15.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg15.setText("Opções:");

        javax.swing.GroupLayout jPanelAgendaLayout = new javax.swing.GroupLayout(jPanelAgenda);
        jPanelAgenda.setLayout(jPanelAgendaLayout);
        jPanelAgendaLayout.setHorizontalGroup(
            jPanelAgendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelAgendaLayout.createSequentialGroup()
                .addContainerGap(23, Short.MAX_VALUE)
                .addGroup(jPanelAgendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanelAgendaLayout.createSequentialGroup()
                        .addComponent(jLabelMsg12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jComboBoxProfissional, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanelAgendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelAgendaLayout.createSequentialGroup()
                        .addGap(47, 47, 47)
                        .addComponent(jLabelMsg13))
                    .addGroup(jPanelAgendaLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanelAgendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelMsg15)
                            .addComponent(jCalendarData, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanelAgendaLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelAgendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButtonIncluir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButtonDeletarAgendamentos, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanelAgendaLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabelMsg11, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(20, 20, 20))
        );
        jPanelAgendaLayout.setVerticalGroup(
            jPanelAgendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAgendaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelAgendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg12)
                    .addComponent(jComboBoxProfissional, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelMsg13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelAgendaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanelAgendaLayout.createSequentialGroup()
                        .addComponent(jCalendarData, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabelMsg15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonDeletarAgendamentos, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonIncluir, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabelMsg11))
                    .addComponent(jScrollPane3))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jTabbed.addTab("Agenda", jPanelAgenda);

        jPanelDetalhes.setBackground(new java.awt.Color(255, 102, 0));
        jPanelDetalhes.setBorder(javax.swing.BorderFactory.createMatteBorder(3, 3, 3, 3, new java.awt.Color(0, 0, 0)));

        jLabelMsg19.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg19.setText("Código:");

        jTextFieldCodigo.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigo.setEnabled(false);
        jTextFieldCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigoActionPerformed(evt);
            }
        });

        jLabelMsg16.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg16.setText("Horário:");

        jTextFieldAnimal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldAnimal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldAnimalActionPerformed(evt);
            }
        });

        jButtonBuscarAnimal.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBuscarAnimal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonBuscarAnimal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonBuscarAnimal.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonBuscarAnimal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarAnimalActionPerformed(evt);
            }
        });

        jLabelMsg17.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg17.setText("<html><u>Animal:</u></html>");
        jLabelMsg17.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg17jLabelMsg17MouseClicked(evt);
            }
        });

        jLabelMsg18.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg18.setText("<html><u>Dono:</html></u>");
        jLabelMsg18.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg18MouseClicked(evt);
            }
        });

        jTextFieldDono.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldDono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldDonoActionPerformed(evt);
            }
        });

        jTextFieldAddServico.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldAddServico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldAddServicoActionPerformed(evt);
            }
        });
        jTextFieldAddServico.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldAddServicoKeyPressed(evt);
            }
        });

        jLabelMsg20.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg20.setText("Serviços:");

        jButtonAdicionarServico.setBackground(new java.awt.Color(255, 255, 255));
        jButtonAdicionarServico.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonAdicionarServico.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonAdicionarServico.setText("Adicionar");
        jButtonAdicionarServico.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonAdicionarServico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAdicionarServicoActionPerformed(evt);
            }
        });

        jButtonDeletarServico.setBackground(new java.awt.Color(255, 255, 255));
        jButtonDeletarServico.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonDeletarServico.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonDeletarServico.setText("Deletar Serviço");
        jButtonDeletarServico.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonDeletarServico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDeletarServicoActionPerformed(evt);
            }
        });

        jTextFieldCodigoAnimal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigoAnimal.setEnabled(false);
        jTextFieldCodigoAnimal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigoAnimalActionPerformed(evt);
            }
        });

        jLabelMsg21.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg21.setText("Código:");

        jLabelMsg22.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg22.setText("Código:");

        jTextFieldCodigoDono.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigoDono.setEnabled(false);
        jTextFieldCodigoDono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigoDonoActionPerformed(evt);
            }
        });

        jTableServiços.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
        jTableServiços.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jTableServiços.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Descrição", "Duração", "Preço"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableServiços.setRowHeight(20);
        jScrollPane4.setViewportView(jTableServiços);

        jLabelMsg23.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg23.setText("Observações:");

        jTextPaneObservacoes.setEditable(false);
        jTextPaneObservacoes.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jScrollPane6.setViewportView(jTextPaneObservacoes);

        jButtonReagendar.setBackground(new java.awt.Color(255, 255, 255));
        jButtonReagendar.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonReagendar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonReagendar.setText("Alterar data/horário");
        jButtonReagendar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonReagendar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonReagendarActionPerformed(evt);
            }
        });

        jButtonEditar.setBackground(new java.awt.Color(255, 255, 255));
        jButtonEditar.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonEditar.setText("Editar Agendamento");
        jButtonEditar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditarActionPerformed(evt);
            }
        });

        jLabelHora.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N

        jLabelProfissional.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N

        jLabelMsg26.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg26.setText("Profissional:");

        javax.swing.GroupLayout jPanelDetalhesLayout = new javax.swing.GroupLayout(jPanelDetalhes);
        jPanelDetalhes.setLayout(jPanelDetalhesLayout);
        jPanelDetalhesLayout.setHorizontalGroup(
            jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jScrollPane4)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelDetalhesLayout.createSequentialGroup()
                                .addComponent(jLabelMsg20)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jTextFieldAddServico, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButtonAdicionarServico)
                                .addGap(68, 68, 68)
                                .addComponent(jButtonDeletarServico))
                            .addComponent(jScrollPane6)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelDetalhesLayout.createSequentialGroup()
                                .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelDetalhesLayout.createSequentialGroup()
                                        .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                                                .addComponent(jLabelMsg19)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                                                .addComponent(jLabelMsg16)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jLabelHora, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabelMsg26)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabelProfissional, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabelMsg23)
                                        .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                                            .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabelMsg17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabelMsg18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                                                    .addComponent(jTextFieldAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jButtonBuscarAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addComponent(jTextFieldDono, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                                                    .addComponent(jLabelMsg21)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jTextFieldCodigoAnimal))
                                                .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                                                    .addComponent(jLabelMsg22)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jTextFieldCodigoDono, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                                .addGap(6, 6, 6))))
                    .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                        .addGap(69, 69, 69)
                        .addComponent(jButtonEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(43, 43, 43)
                        .addComponent(jButtonReagendar)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelDetalhesLayout.setVerticalGroup(
            jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelMsg19)
                            .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelMsg16)
                            .addComponent(jLabelHora, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanelDetalhesLayout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelMsg26, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabelProfissional, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabelMsg17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextFieldAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButtonBuscarAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabelMsg21)
                        .addComponent(jTextFieldCodigoAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(14, 14, 14)
                .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldDono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelMsg18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelMsg22)
                    .addComponent(jTextFieldCodigoDono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabelMsg23)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg20)
                    .addComponent(jTextFieldAddServico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonAdicionarServico, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonDeletarServico))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDetalhesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonReagendar, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(19, 19, 19))
        );

        jTabbed.addTab("Detalhes", jPanelDetalhes);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(75, 75, 75)
                        .addComponent(jLabelMsg14))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbed, javax.swing.GroupLayout.PREFERRED_SIZE, 602, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jLabelMsg14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbed, javax.swing.GroupLayout.PREFERRED_SIZE, 598, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBoxProfissionalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxProfissionalActionPerformed
        if (jComboBoxProfissional.getSelectedIndex() == 0) {
            tabela();
            tabelaServicos();
            jTextFieldCodigo.setText(null);
            jTextFieldAnimal.setText(null);
            jTextFieldCodigoAnimal.setText(null);
            jTextFieldCodigoDono.setText(null);
            jTextFieldDono.setText(null);
            jTextPaneObservacoes.setText(null);
            jLabelHora.setText(null);
            jLabelProfissional.setText(null);
        } else {

            /*Buscar agenda do profissional no banco*/
        }
    }//GEN-LAST:event_jComboBoxProfissionalActionPerformed

    private void jButtonIncluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonIncluirActionPerformed
        if (flag2 == 1) {
            if (jComboBoxProfissional.getSelectedIndex() == 0) {
                bloqueio("<html>Nenhum profissional selecionado! <br>"
                        + "Por favor, selecione o profissional"
                        + " que deseja incluir/editar um novo agendamento!</html>");
            } else {
                try {
                    if (jTableAgenda.getValueAt(jTableAgenda.getSelectedRow(), 1).toString().length() == 0) {

                        IncluirAgendamento ia = new IncluirAgendamento(null, true,
                                jCalendarData.getDate(),
                                (String) jTableAgenda.getValueAt(jTableAgenda.getSelectedRow(), 0),
                                (String) jComboBoxProfissional.getSelectedItem());
                        ia.setLocationRelativeTo(null);
                        ia.setVisible(true);

                    } else {
                        bloqueio("<html>Já existe um agendamento no horário selecionado! <br>"
                                + "Por favor, selecione um horários vago para transferir"
                                + " o agendamento selecionado!</html>");
                    }
                } catch (Exception ex) {
                    bloqueio("<html>Nenhum horário foi selecionado! <br>"
                            + "Por favor, selecione um dos horários vagos para a alteração"
                            + " do agendamento selecionado!</html>");
                    System.out.println(ex);
                }
            }
        } else {

        }

    }//GEN-LAST:event_jButtonIncluirActionPerformed

    private void jButtonDeletarAgendamentosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeletarAgendamentosActionPerformed
        if (flag2 == 0) {
            this.dispose();
        } else {
            try {
                if (jTableAgenda.getValueAt(jTableAgenda.getSelectedRow(), 1).equals("")) {
                    bloqueio("<html>Não há agendamento no horário selecionado! <br>"
                            + "Por favor, selecione um agendamento válido para"
                            + " esta ação!</html>");
                } else {
                    SimNao sn = new SimNao(null, true, "<html>Tem certeza"
                            + " que deseja deletar o agendamento de </html>"
                            + jTableAgenda.getValueAt(jTableAgenda.getSelectedRow(), 2) + " definitivamente?", 11);
                    sn.setLocationRelativeTo(null);
                    sn.setVisible(true);

                    if (conf == true) {
                        //limpar tabela
                        jTableAgenda.setValueAt("", jTableAgenda.getSelectedRow(), 1);
                        jTableAgenda.setValueAt("", jTableAgenda.getSelectedRow(), 2);
                        //limpar campos
                        limpar();
                        /*
                         Deletar do banco de dados
                         */
                    }
                }
            } catch (Exception ex) {
                bloqueio("<html>Nenhum agendamento selecionado! <br>"
                        + "Por favor, selecione o agendamento que deseja"
                        + "deletar antes de prosseguir!</html>");
            }
        }
    }//GEN-LAST:event_jButtonDeletarAgendamentosActionPerformed

    private void jTextFieldCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigoActionPerformed

    }//GEN-LAST:event_jTextFieldCodigoActionPerformed

    private void jTextFieldAnimalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldAnimalActionPerformed

    }//GEN-LAST:event_jTextFieldAnimalActionPerformed

    private void jButtonBuscarAnimalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarAnimalActionPerformed
        try {
            AnimaisCadastrados a = new AnimaisCadastrados(null, true, 2);
            a.setLocationRelativeTo(null);
            a.setVisible(true);
        } catch (Exception ex) {
            System.out.println(ex);
        }
    }//GEN-LAST:event_jButtonBuscarAnimalActionPerformed

    private void jLabelMsg17jLabelMsg17MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg17jLabelMsg17MouseClicked

    }//GEN-LAST:event_jLabelMsg17jLabelMsg17MouseClicked

    private void jLabelMsg18MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg18MouseClicked

    }//GEN-LAST:event_jLabelMsg18MouseClicked

    private void jTextFieldDonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldDonoActionPerformed

    }//GEN-LAST:event_jTextFieldDonoActionPerformed

    private void jTextFieldAddServicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldAddServicoActionPerformed

    }//GEN-LAST:event_jTextFieldAddServicoActionPerformed

    private void jButtonAdicionarServicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAdicionarServicoActionPerformed

    }//GEN-LAST:event_jButtonAdicionarServicoActionPerformed

    private void jButtonDeletarServicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeletarServicoActionPerformed
        int[] linha = jTableServiços.getSelectedRows();
        if (linha.length == 0) {
            bloqueio("<html>Nenhum serviço selecionado!<br>"
                    + "Por favor, selecione "
                    + "os serviços que deseja retirar deste agendamento!<html>");
        } else {
            for (int i = 0; i < linha.length; i++) {
                modelaS.removeRow(linha[0]);
            }
            jTableServiços.setModel(modelaS);
        }
    }//GEN-LAST:event_jButtonDeletarServicoActionPerformed

    private void jTextFieldCodigoAnimalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigoAnimalActionPerformed

    }//GEN-LAST:event_jTextFieldCodigoAnimalActionPerformed

    private void jTextFieldCodigoDonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigoDonoActionPerformed

    }//GEN-LAST:event_jTextFieldCodigoDonoActionPerformed

    private void jButtonReagendarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonReagendarActionPerformed
        try {
            if (jTableAgenda.getValueAt(jTableAgenda.getSelectedRow(), 1).toString().equals("")) {
                bloqueio("<html>Não há agendamento no horário selecionado! <br>"
                        + "Por favor, selecione agendamento válido para a troca de "
                        + "horário!</html>");
            } else {
                AgendaBanhoTosa tel = new AgendaBanhoTosa(null, true, 0, Integer.parseInt(jTextFieldCodigo.getText()));
                tel.setLocationRelativeTo(null);
                tel.setVisible(true);
            }
        } catch (Exception ex) {
            bloqueio("<html>Nenhum agendamento foi selecionado! <br>"
                    + "Por favor, selecione o agendamento que deseja trocar "
                    + "de horário!</html>");
        }
    }//GEN-LAST:event_jButtonReagendarActionPerformed

    private void jButtonEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditarActionPerformed
        try {
            if (jTableAgenda.getValueAt(jTableAgenda.getSelectedRow(), 1).equals("")) {
                bloqueio("<html>Não há agendamentos "
                        + "no horário selecionado! <br> Por favor, selecione um agendamento "
                        + "válido para a edição!</html>");
            } else {
                //dentro do salvar
                if (flag == 0) {
                    //Não deixar salvar sem serviços
                    if (jTableServiços.getRowCount() > 0) {
                        jButtonEditar.setText("Editar");
                        habilita(false, true);
                        //mudar para função editar
                        flag = 1;
                    } else {
                        bloqueio("<html>Todos os serviços "
                                + "foram retirados!<br>"
                                + "Por favor, adicione no mínimo um serviço"
                                + " para prosseguir!</html>");
                    }

                } else {
                    jButtonEditar.setText("Salvar");
                    habilita(true, false);
                    flag = 0;
                }
            }
        } catch (Exception ex) {
            bloqueio("<html>Nenhum agendamento selecionado! <br> Por favor, selecione um dos "
                    + "agendamentos para prosseguir com as edições!</html>");
        }


    }//GEN-LAST:event_jButtonEditarActionPerformed

    private void jTextFieldAddServicoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldAddServicoKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            if (jTextFieldAddServico.getText().length() == 0) {
                bloqueio("<html>Nenhum código descrito!<br>"
                        + "Por favor, insira o código de um serviço "
                        + "cadastrado para prosseguir!</html>");
            } else {
                /*
                 Buscar código digitado no banco e jogar na tabela
                 colocar um if/else para ver se o código existe
                 */
                modelaS.addRow(new String[]{jTextFieldAddServico.getText(), "kjhg",
                    "8", "5"});
                jTextFieldAddServico.setText(null);
            }
        }
    }//GEN-LAST:event_jTextFieldAddServicoKeyPressed

    private void jTableAgendaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableAgendaMouseClicked
        int linha = jTableAgenda.getSelectedRow();
        if (jTableAgenda.getValueAt(linha, 1).toString().length() > 0) {
            jLabelHora.setText((String) jTableAgenda.getValueAt(linha, 0));
            jTextFieldCodigo.setText((String) jTableAgenda.getValueAt(linha, 1));
            jTextFieldAnimal.setText((String) jTableAgenda.getValueAt(linha, 2));
            jLabelProfissional.setText((String) jComboBoxProfissional.getSelectedItem());
            jTextFieldCodigoAnimal.setText("00055");
            jTextFieldDono.setText("O dono vai aqui");
            jTextFieldCodigoDono.setText("00005");
            jTextPaneObservacoes.setText("As observações do banho vão aqui");
            tabelaServicos();
            //preencher tabela de serviços a serem realizados no agendamento

        } else {
            limpar();
        }
    }//GEN-LAST:event_jTableAgendaMouseClicked

    private void jCalendar1PropertyChange(java.beans.PropertyChangeEvent evt) {

        try {
            if (jComboBoxProfissional.getSelectedIndex() == 0) {
                bloqueio("<html>Nenhum profissional selecionado!<br>"
                        + "Por favor, escolha qual profissional deseja pesquisar"
                        + "os agendamentos da data escolhida!</html>");
            } else {
                jComboBoxProfissional.getSelectedItem();
                String data = formatar.format(jCalendarData.getDate());
                System.out.println(data);
                /*
            
                 Buscar no banco de dados os agendamentos do profissional selecionado
            
                 */
            }
        } catch (Exception ex) {
            System.out.println(ex);
        }

    }

    public static void main(String args[]) {
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;

                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AgendaBanhoTosa.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AgendaBanhoTosa.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AgendaBanhoTosa.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AgendaBanhoTosa.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                AgendaBanhoTosa dialog = new AgendaBanhoTosa(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAdicionarServico;
    private javax.swing.JButton jButtonBuscarAnimal;
    private javax.swing.JButton jButtonDeletarAgendamentos;
    private javax.swing.JButton jButtonDeletarServico;
    private javax.swing.JButton jButtonEditar;
    private javax.swing.JButton jButtonIncluir;
    private javax.swing.JButton jButtonReagendar;
    private com.toedter.calendar.JCalendar jCalendarData;
    public static javax.swing.JComboBox jComboBoxProfissional;
    private javax.swing.JLabel jLabelHora;
    private javax.swing.JLabel jLabelMsg11;
    private javax.swing.JLabel jLabelMsg12;
    private javax.swing.JLabel jLabelMsg13;
    private javax.swing.JLabel jLabelMsg14;
    private javax.swing.JLabel jLabelMsg15;
    private javax.swing.JLabel jLabelMsg16;
    private javax.swing.JLabel jLabelMsg17;
    private javax.swing.JLabel jLabelMsg18;
    private javax.swing.JLabel jLabelMsg19;
    private javax.swing.JLabel jLabelMsg20;
    private javax.swing.JLabel jLabelMsg21;
    private javax.swing.JLabel jLabelMsg22;
    private javax.swing.JLabel jLabelMsg23;
    private javax.swing.JLabel jLabelMsg26;
    private javax.swing.JLabel jLabelProfissional;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanelAgenda;
    private javax.swing.JPanel jPanelDetalhes;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbed;
    private javax.swing.JTable jTableAgenda;
    private javax.swing.JTable jTableServiços;
    public static javax.swing.JTextField jTextFieldAddServico;
    public static javax.swing.JTextField jTextFieldAnimal;
    public static javax.swing.JTextField jTextFieldCodigo;
    public static javax.swing.JTextField jTextFieldCodigoAnimal;
    public static javax.swing.JTextField jTextFieldCodigoDono;
    public static javax.swing.JTextField jTextFieldDono;
    public static javax.swing.JTextPane jTextPaneObservacoes;
    // End of variables declaration//GEN-END:variables
}
